<?php $this->load->view("_header") ?>
<html>
<body>
	<script type="text/javascript">
$(
	function()
	{	
		$.formValidator.initConfig(
			{
				autotip: true,
			});
		$("#tbxLoginNickname")
			.formValidator(
				{
					tipid: "loginNickname",
					onshow: "",
					onfocus: "",
					oncorrect: ""
				})
			.inputValidator(
				{
					min: 1,
					onerror: "请填写用户名"
				});
		$("#tbxLoginPassword")
			.formValidator(
				{
					tipid: "loginPassword",
					onshow: "",
					onfocus: "",
					oncorrect: ""
				})
			.inputValidator(
				{
					min: 1,
					onerror: "请填写密码"
				});
		$("#tbxLoginVerifier")
			.formValidator(
				{
					tipid: "loginVerifier",
					onshow: "",
					onfocus: "",
					oncorrect: ""
				})
			.inputValidator(
				{
					min: 1,
					onerror: "请填写验证码"
				});
		$(":input").focus(
			function()
			{
				var settings = $(this).attr("settings");
				if (settings != null && settings.length > 0)
				{
					$.formValidator.resetTipState("1");
				}
			});

		$.formValidator.initConfig(
				{
					autotip: true,
					validatorgroup: "2"
				});
			$("#tbxRegisterNickname")
				.formValidator(
					{
						validatorgroup: "2",
						tipid: "registerNickname",
						onshow: "4-20位字符，可由中英文、数字及“_”、“-”组成",
						onfocus: "",
						oncorrect: ""
					})
				.inputValidator(
					{
						min: 4,
						max: 20,
						onerror: "用户名长度只能在4-20位字符之间"
					})
				.regexValidator(
					{
						regexp: "username",
						datatype: "enum",
						onerror: "用户名只能由中英文、数字及“_”、“-”组成"
					}); 
			$("#tbxRegisterNickname")
				.ajaxValidator(
					{
						type: "GET",
						url: '<?php echo site_url('register/check_name')?>',
						datatype: "json",
						success:
							function(result)
							{
								return result.Result;
							},
						buttons: $("#ibtRegister"),
						onwait: "正在检测用户名是否重复...",
						onerror: "该用户名已被使用"
					});
			$("#tbxRegisterPassword")
				.formValidator(
					{
						validatorgroup: "2",
						tipid: "registerPassword",
						onshow: "6-16位字符，可由英文、数字及“_”、“-”组成",
						onfocus: "",
						oncorrect: ""
					})
				.inputValidator(
					{
						min: 6,
						max: 16,
						onerror: "密码长度只能在6-16位字符之间"
					})
				.regexValidator(
					{
						regexp: "password",
						datatype: "enum",
						onerror: "密码只能由英文、数字及“_”、“-”组成"
					});
			$("#tbxRegisterPassword").keyup(
				function()
				{
					var strength = checkPasswordStrength($(this).val());
					if (strength)
					{
						$("#pwdStrengh").show();
					}
					else
					{
						$("#pwdStrengh").hide();
					}
					$("#pwdStrengh").attr("className", strength);
				});
			$("#tbxRegisterRepeatPassword")
				.formValidator(
					{
						validatorgroup: "2",
						tipid: "registerRepeatPassword",
						onshow: "",
						onfocus: "",
						oncorrect: ""
					})
				.compareValidator(
					{
						desid: "tbxRegisterPassword",
						operateor: "=",
						onerror: "两次输入的密码不一致"
					});
			$("#tbxRegisterVerifier")
				.formValidator(
					{
						validatorgroup: "2",
						tipid: "registerVerifier",
						onshow: "",
						onfocus: "",
						oncorrect: ""
					})
				.inputValidator(
					{
						min: 1,
						onerror: "请填写验证码"
					});
			$("#choose")
				.formValidator(
					{
						validatorgroup: "2",
						tipid: "agreement",
						onshow: "",
						onfocus: "",
						oncorrect: ""
					})
				.inputValidator(
					{
						min: 1,
						onerror: "请阅读并同意《xx用户协议》"
					});
			
			$(":input").focus(
				function()
				{
					var settings = $(this).attr("settings");
					if (settings != null && settings.length > 0)
					{
						var group = settings[0].validatorgroup;
						if (group == "1")
						{
							$.formValidator.resetTipState("2");
						}
						else if (group == "2")
						{
							$.formValidator.resetTipState("1");
						}
					}
				});
			
	});

var msg = '<?php echo $error_msg; ?>';
$(document).ready(function() {
	if (msg != 0){
		switch (msg){
			case 'verifier1' : $('#cvlLoginVerifier').show();break;
			case 'customer' : $('#cvlLoginUser').show();break;
			default : break;
		}
	}	
});

function change_yzm(obj)
{
    $(obj).attr('src','<?php echo site_url('login/yzm_img')?>'+'/'+Math.random());
}

function change_action(group)
{
	$('#form1').attr('action','<?php echo site_url('login/check_customer')?>')	
}

function do_register()
{
	$('#loginBg').hide();
	$('#reg').css("display", "block");
}

function register_reset()
{
	$('#tbxRegisterNickname').val("");
	$('#tbxRegisterPassword').val("");
	$('#tbxRegisterRepeatPassword').val("");
	$('#tbxRegisterFirstName').val("");
	$('#tbxRegisterLastName').val("");
	$('#tbxRegisterBirthday').val("");
	$('#selRegisterSex').val("1");
	$('#hflRegisterCity').val("0");
	$('#tbxRegisterVerifier').val("");
	$('#choose').attr("checked", "checked");
	$.formValidator.resetTipState("1");
	$.formValidator.resetTipState("2");
}

var msg = '<?php echo $error_msg; ?>';
$(document).ready(function() {
	if (msg != 0){
		switch (msg){
			case 'verifier' : $('#cvlRegister').empty().text('验证码错误').show();break;
			default : break;
		}
	}	
});

function change_yzm1(obj)
{
    $(obj).attr('src','<?php echo site_url('register/yzm_img')?>'+'/'+Math.random());
}

function checkPasswordStrength(password)
{
	var result = "";
	var strength = 0;
	if (password.length >= 6)
	{
		if (/\d/i.test(password))
		{
			strength += 30;
		}
		if (/[a-z]/i.test(password))
		{
			strength += 30;
		}
		if (/[-_]/i.test(password))
		{
			strength += 30;
		}
	}
	switch (strength)
	{
		case 30:
			result = "strenghA";
			break;
		case 60:
			result = "strenghB";
			break;
		case 90:
			result = "strenghC";
			break;
	}
	
	return result;
}

function validate(group)
{
	if (group == "1")
	{
		$.formValidator.resetTipState("2");
	}
	else if (group == "2")
	{
		$.formValidator.resetTipState("1");
	}
	
	return $.formValidator.pageIsValid(group);
}

</script>
	<form name="form1" method="post"
		action="<?php echo site_url('register/save')?>"
		onsubmit="javascript:return WebForm_OnSubmit();" id="form1">
		<div class="Main">

			<div class="mleft">
				<table border='0' bgcolor="#8EB4E3" height=120>
					<tr>
						<td>
							<div>
								<div class="lo_child">
									<font color="#fff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户名：</font><input
										value="" name="tbxLoginNickname" maxlength="20"
										id="tbxLoginNickname" type="text">
									<div style="display: none;" id="loginNickname"></div>
								</div>
								<div class="lo_child">
									<font color="#fff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;码：</font><input
										name="tbxLoginPassword" maxlength="50" id="tbxLoginPassword"
										type="password">
									<div style="display: none;" id="loginPassword"></div>
									<div class="onError">
										<span id="cvlLoginUser" style="color: Red; display: none;">用户名或密码错误</span>
									</div>
								</div>
								<div style="height: 200px;">
									<div id="pnlVerifier" class="lo_child yzm">
										<font color="#fff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码：</font><input
											name="tbxLoginVerifier" maxlength="5" id="tbxLoginVerifier"
											autocomplete="off" type="text">
										<div class="onError" style="overflow: hidden;">
											<span id="cvlLoginVerifier"
												style="color: Red; display: none; float: left; margin-right: 5px;">验证码错误</span>
											<em id="loginVerifier"
												style="padding-left: 0pt; float: left; display: none;"></em>
										</div>
										<input name="hflLoginTimes" id="hflLoginTimes" type="hidden">
										<div class="yzm_img">
											<img src="<?php echo site_url('login/yzm_img')?>"
												id="ivrLoginVerifier" onclick="change_yzm(this)">
										</div>
									</div>
									<div class="adminChk">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<font color="#fff"><label>管理员&nbsp;&nbsp;</label></font><input
											name="tbxAdmin" maxlength="50" id="tbxAdmin" type="checkbox">
											<br /><br />
									</div>
									<div>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input name="ibtLogin" id="ibtLogin"
											src="<?php echo base_url()?>images/Login_button_login.jpg"
											onclick="change_action('1');return validate('1');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ibtLogin&quot;, &quot;&quot;, true, &quot;1&quot;, &quot;&quot;, false, false))"
											style="border-width: 0px;" type="image">&nbsp; <input
											name="ibtLogin" id="ibtLogin"
											src="<?php echo base_url()?>images/Login_button_register.jpg"
											onclick="do_register();return false;"
											style="border-width: 0px;" type="image">&nbsp;
									</div>
								</div>
							</div>

						</td>
					</tr>
				</table>
			</div>
			<!-- /mleft -->
			<div class="mright" id="loginBg">
				<img src="<?php echo base_url()?>images/Login_bg_01.jpg"></img>
			</div>

			<div class="mright" id="reg" style="display: none">
				<table border='0' height=120 style="table-layout: fixed"
					class="mright">
					<tr bgcolor="#4F81db" height=60>
						<td style="word-wrap: break-all">
							<div class="onError">
								<span id="cvlRegister" style="color: Red; display: none;">注册信息错误</span>
							</div>
							<div>
								<font color="#fff">用户名：</font>
							</div>
						</td>
						<td style="word-wrap: break-all">
							<div>
								<input name="tbxRegisterNickname" maxlength="20"
									id="tbxRegisterNickname" type="text">
								<div class="onShow" id="registerNickname">4-20位字符，可由中英文、数字及“_”、“-”组成</div>
								<input name="hflRegisterNickname" id="hflRegisterNickname"
									type="hidden">
							</div>
						</td>
					</tr>
					<tr bgcolor="#D0D8E8" height=60>
						<td style="word-wrap: break-all">密码：</td>
						<td style="word-wrap: break-all">
							<div>
								<input name="tbxRegisterPassword" maxlength="16"
									id="tbxRegisterPassword" type="password">
								<div id="pwdStrengh" style="display: none;">密码强度：</div>
								<div class="onShow" id="registerPassword">6-16位字符，可由英文、数字及“_”、“-”组成</div>
								<input name="hflRegisterPassword" id="hflRegisterPassword"
									type="hidden">
							</div>
						</td>
					</tr>
					<tr bgcolor="#E9EDF4" height=60>
						<td style="word-wrap: break-all">密码确认：</td>
						<td style="word-wrap: break-all"><input
							name="tbxRegisterRepeatPassword" maxlength="16"
							id="tbxRegisterRepeatPassword" type="password">
							<div style="display: none;" id="registerRepeatPassword"></div>
						</td>
					</tr>
					<tr bgcolor="#D0D8E8" height=60>
						<td style="word-wrap: break-all">姓：</td>
						<td style="word-wrap: break-all"><input
							name="tbxRegisterLastName" maxlength="50"
							id="tbxRegisterLastName" type="text"> <input
							name="hflRegisterFirstName" id="hflRegisterFirstName"
							type="hidden">
						</td>
					</tr>
					<tr bgcolor="#E9EDF4" height=60>
						<td style="word-wrap: break-all">名：</td>
						<td style="word-wrap: break-all"><input name="tbxRegisterFirstName"
							maxlength="50" id="tbxRegisterFirstName" type="text"> <input
							name="hflRegisterLastName" id="hflRegisterLastName" type="hidden">
						</td>
					</tr>
					<tr bgcolor="#D0D8E8" height=60>
						<td style="word-wrap: break-all">生日：</td>
						<td style="word-wrap: break-all"><input name="tbxRegisterBirthday"
							maxlength="50" id="tbxRegisterBirthday" type="text"> <input
							name="hflRegisterBirthday" id="hflRegisterBirthday" type="hidden">
						</td>
					</tr>
					<tr bgcolor="#E9EDF4" height=60>
						<td style="word-wrap: break-all">姓别：</td>
						<td style="word-wrap: break-all"><select name="selRegisterSex"
							id="selRegisterSex">
								<option value="1">男</option>
								<option value="0">女</option>
						</select> <input name="hflRegisterSex" id="hflRegisterSex"
							type="hidden">
						</td>
					</tr>
					<tr bgcolor="#D0D8E8" height=60>
						<td style="word-wrap: break-all">所在城市：</td>
						<td style="word-wrap: break-all"><select name="selRegisterCity"
							id="selRegisterCity">
								<option value="0">北京</option>
								<option value="1">上海</option>
						</select> <input name="hflRegisterCity" id="hflRegisterCity"
							type="hidden">
						</td>
					</tr>
					<tr>
						<td style="word-wrap: break-all">
							<div class="lo_child yzm">
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码：<input
									name="tbxRegisterVerifier" maxlength="5"
									id="tbxRegisterVerifier" autocomplete="off" type="text">
								<div style="display: none;" id="registerVerifier"></div>
								<div class="yzm_img">
									<img src="<?php echo site_url('register/yzm_img')?>"
										id="ivrRegisterVerifier" onclick="change_yzm1(this)" />
								</div>
							</div>

							<div class="lo_child align_Center">
								<input id="choose" class="radio" checked="checked"
									type="checkbox">我已阅读并同意<a href="" target="_blank">《xx用户协议》</a>
								<div style="display: none;" id="agreement"></div>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div style="display: inline">
								<center>
									<input name="ibtRegister" id="ibtRegister"
										src="<?php echo base_url()?>images/Register_button_submit.jpg"
										onclick="return validate('2');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ibtRegister&quot;, &quot;&quot;, true, &quot;2&quot;, &quot;&quot;, false, false))"
										style="border-width: 0px;" type="image">
								</center>
							</div>

						</td>
						<td>
							<div style="display: inline">
								<center>
									<input name="ibtReset" id="ibtReset"
										src="<?php echo base_url()?>images/Register_button_reset.jpg"
										onclick="register_reset(); return false;"
										style="border-width: 0px;" type="image">
								</center>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<!-- /Main -->
	</form>
	<script type="text/javascript">
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</script>
	<script type="text/javascript"
		src="<?php echo base_url()?>js/jquery_002.js">
</script>

	<?php $this->load->view("_footer") ?>